﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="/">
    <jobs>
      <xsl:for-each select="/document/menu-item">
        <xsl:call-template name="tpl-export-views">
          <xsl:with-param name="node" select="."/>
        </xsl:call-template>
      </xsl:for-each>
    </jobs>
  </xsl:template>

  <xsl:template name="tpl-export-views">
    <xsl:param name="node"/>

    <xsl:if test="count($node/views/view) &gt; 0">
      <gen-view>
        <xsl:attribute name="module">
          <xsl:value-of select="$node/@module"/>
        </xsl:attribute>
        <xsl:attribute name="file">
          <xsl:value-of select="$node/views/@file"/>
        </xsl:attribute>
        <xsl:attribute name="title">
          <xsl:value-of select="$node/@title"/>
        </xsl:attribute>
        <xsl:attribute name="model">
          <xsl:value-of select="$node/@model"/>
        </xsl:attribute>
        <xsl:attribute name="grid-view">
          <xsl:value-of select="$node/views/view[@type='grid']/@name"/>
        </xsl:attribute>
        <xsl:attribute name="form-view">
          <xsl:value-of select="$node/views/view[@type='form']/@name"/>
        </xsl:attribute>
      </gen-view>
    </xsl:if>

    <xsl:for-each select="$node/menu-item">
      <xsl:call-template name="tpl-export-views">
        <xsl:with-param name="node" select="."/>
      </xsl:call-template>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>
